/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: MENG
 * Date: 2022-07-13
 * Time: 21:51
 */
public class TestDemo {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        //创建根节点
        BinaryTree.TreeNode root = binaryTree.createTree();

        System.out.println("前序遍历");
        binaryTree.preOrder(root);
        System.out.println();

        System.out.println("中序遍历");
        binaryTree.inOrder(root);
        System.out.println();

        System.out.println("后序遍历");
        binaryTree.postOrder(root);
        System.out.println();

        System.out.println("层序遍历");
        binaryTree.levelOrder(root);
        System.out.println();

        System.out.println("节点的个数1："+ binaryTree.size(root));
        binaryTree.size2(root);
        System.out.println("节点的个数2："+ BinaryTree.nodeSize);
        System.out.println("===============");

        System.out.println("叶子节点个数1："+ binaryTree.getLeafNodeCount(root));
        binaryTree.getLeafNodeCount2(root);
        System.out.println("叶子节点个数2："+ BinaryTree.leafSize);

        System.out.println("第K层节点的个数："+binaryTree.getKLevelNodeCount(root,4));
        System.out.println("高度："+binaryTree.getHeight(root));
        //返回值是TreeNode类型的，想要打印出来找到的元素得TreeNode.val，但是元素如果没有返回null，就会发生null.val空指针异常()补充一下笔记
        System.out.println("查找节点："+ binaryTree.find(root,'E').val);


    }


}
